package com.hx.portal.controller.order;

import com.hx.common.exception.CustomerException;
import com.hx.common.exception.MessageCode;
import com.hx.common.result.Result;
import com.hx.common.result.ResultUtils;
import com.hx.order.dto.OrderDto;
import com.hx.order.dto.ReservationDto;
import com.hx.order.pojo.Content;
import com.hx.order.pojo.Order;
import com.hx.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 中二啊
 * @program: parent
 * @description: 订单门户
 * @date 2021-01-21 12:27:16
 */
@RestController
@RequestMapping("/order")
@Api(description = "订单相关接口文档")
public class OrderController {

    @Reference
    private OrderService orderService;

    @ApiOperation(value = "查询当前用户下的预约信息",notes = "查询当前用户下的预约信息",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @GetMapping("/findByUserId/{id}")
    public List<Order> findByUserId(@PathVariable("id") Integer id){

        return orderService.findAppointmentInformation(Long.valueOf(id));
    }
    @ApiOperation(value = "添加当前就诊人预约",notes = "添加当前就诊人预约",httpMethod = "POST")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @PostMapping("/addReservation")
    public Result addReservation(@RequestBody OrderDto orderDto)  {
        try{
        String order = orderService.createOrder(orderDto);
        return new Result(0,order);}
        catch (CustomerException e){
            return ResultUtils.buildFail(e.getMessageCode());
        }
    }
    @ApiOperation(value = "查询当前就诊人的具体某一条的预约信息",notes = "查询当前就诊人的具体某一条的预约信息",httpMethod = "POST")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @PostMapping("/findReservationOne/{id}")
    public ReservationDto findReservationOne(@PathVariable("id") String id){
        Order order = orderService.findById(id);
        return null;
    }

    @ApiOperation(value = "查询具体某一个报告表",notes = "查询报告表",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @GetMapping("/findReport/{id}")
    public Result findReportOne(@PathVariable("id") Integer id){

        return new Result();
    }

    @ApiOperation(value = "查询持卡人的报告列表",notes = "查询持卡人的报告列表",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @GetMapping("/findReportList/{id}")
    public List<ReservationDto> findReportList(@PathVariable("id") Integer id){
        return null;
    }

    


}
